// 添加方法。为了兼容FireFox、Chrome。
if (!window.ActiveXObject)
{
    XMLDocument.prototype.selectSingleNode = Element.prototype.selectSingleNode = function(xpath)
    {
        var  x = this.selectNodes(xpath)
        if ( ! x || x.length < 1 ) return   null ;
        return  x[0];
    }
	XMLDocument.prototype.selectNodes = Element.prototype.selectNodes = function (xpath)
	{
    	var xpe = new  XPathEvaluator();
        var nsResolver  =  xpe.createNSResolver( this.ownerDocument == null?this.documentElement : this.ownerDocument.documentElement);
        var result = xpe.evaluate(xpath, this, nsResolver, 0 , null);
        var found = [];
        var res;
        while(res = result.iterateNext())
        	found.push(res);
        return found;
	}
}

//加载XML文件并返回XML文档节点
function loadXmlFile(xmlFile){
	var xmlDom = null;
	if (window.ActiveXObject){
		xmlDom = new ActiveXObject('Microsoft.XMLDOM');
		xmlDom.loadXML(xmlFile);//如果用的是XML字符串
		//xmlDom.load(xmlFile);//如果用的是xml文件。
	}else if (document.implementation && document.implementation.createDocument){
		var parseXml = new DOMParser();
		xmlDom = parseXml.parseFromString(xmlFile, 'text/xml');
	}else{
		xmlDom = null;
	}
	return xmlDom;
}